<template>
    <square-button :icon="icon" :title="title" v-on="$listeners" v-bind="$attrs" @click="toSendRead" :class="className"></square-button>
</template>
<script>
    import SquareButton from "@/components/WorkFlowsDialog/Case/SquareButton";
    import schoolSignature from "@/api/officialDocument/schoolSignature/index"
    import eventBus from "@/utils/eventBus";
    import {mapGetters} from "vuex";
    export default {
        name: "ReadButton",
        components: {SquareButton},
        props: {
            id: {
                type: [Number,String],
                default:0
            },
            type:{
                type:Number,
                default:0
            }
        },
        data() {
            return {
                isCollect: 0
            }
        },
        watch:{
        },
        computed: {
            title(){
                return "已阅"
            },
            icon(){
                return "el-icon-document-checked"
            },
            className(){
                return "read"
            },
            suggestion(){
                return this.$store.getters.msg
            }
        },
        created() {
        },
        methods: {
            toSendRead(){
                let title = "您是否完成阅读？";
                this.$confirm(title, "温馨提示", {
                    confirmButtonText: "是的，完成阅读",
                    cancelButtonText: "放弃，再看看",
                    type: "warning"
                }).then(() => {
                    // console.log("this.suggestion",this.suggestion)
                    // if(this.type<3&&!this.suggestion){
                    //     this.msgError("意见不能为空！")
                    //     return
                    // }
                    schoolSignature.documentDistRead(this.id,{remarks:this.suggestion}).then(res=>{
                        this.msgSuccess("完成已阅！")
                        eventBus.$emit("closeDetailDialog")
                    })
                });
            }
        }
    }
</script>
<style lang="scss" scoped>
    .read {
        background-color: #de4c4a;
        color: #fff;
    }
    .agree-button{
        background-color: #04a65b;
        color: #fff;
        border-color: #04a65b;
    }
</style>
